package lib.model;

import lib.api.bierdopje.model.JBierEpisode;
import lib.api.bierdopje.model.JBierShow;
import lib.logging.Logger;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class EpisodeFile extends VideoFile {

    private String showname;
    private String title;
    private int season;
    private List<Integer> episodeNumbers;
    private JBierShow bierShow;
    private JBierEpisode bierEpisode;

    public EpisodeFile() {
        super(VideoType.EPISODE);
        bierShow = new JBierShow();
        bierEpisode = new JBierEpisode();
        showname = "";
        title = "";
        season = 0;
        episodeNumbers = new ArrayList<Integer>();
    }

    public EpisodeFile(String show, int season, List<Integer> episodeNumbers, File file, String extension, String description) {
        super(VideoType.EPISODE, file, extension, description);
        bierShow = new JBierShow();
        bierEpisode = new JBierEpisode();
        this.showname = show;
        this.season = season;
        this.episodeNumbers = episodeNumbers;
    }

    public void setShow(String show) {
        this.showname = show;
    }

    public String getShow() {
        return showname;
    }

    public void setSeason(int season) {
        this.season = season;
    }

    public int getSeason() {
        return season;
    }

    public void setEpisodeNumbers(List<Integer> episodeNumbers) {
        this.episodeNumbers = episodeNumbers;
    }

    public List<Integer> getEpisodeNumbers() {
        return episodeNumbers;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setBierShow(JBierShow bierShow) {
        this.bierShow = bierShow;
    }

    public JBierShow getBierShow() {
        return bierShow;
    }

    public void setBierEpisode(JBierEpisode bierEpisode) {
        this.bierEpisode = bierEpisode;
    }

    public JBierEpisode getBierEpisode() {
        return bierEpisode;
    }

    public void updateBierShowInfo(JBierShow bierShow) {
    	Logger.instance.trace("EpisodeFile", "updateBierShowInfo", "");
        setShow(bierShow.getName()); // update to reflect correct show name
        setBierShow(bierShow);
    }

    public void updateBierEpisodeInfo(JBierEpisode bierEpisode) {
    	Logger.instance.trace("EpisodeFile", "updateBierEpisodeInfo", "");
    	if (bierEpisode.getTitle().contains("$")){
    		setTitle(bierEpisode.getTitle().replaceAll("\\$", "")); // update to reflect correct episode title and fix for $
    	}else{
    		setTitle(bierEpisode.getTitle()); // update to reflect correct episode title
    	}
        setBierEpisode(bierEpisode);
    }
}